# -*- coding: gb2312 -*-

from StockDailyFactorGeneralFunctions import StockDailyFactorGeneralFunctions
from PeriodFactorGeneralFunctions import PeriodFactorGeneralFunctions
import datetime
import time

class OpenAndRelated:
    def __init__(self):
        self.baseStartDateStr = '2012-01-01'
        #self.baseStartQuarterDateStr = '20120101'
        self.baseEndDateStr = '2017-05-01'

    def writeBaseOpenToMongoDB(self):
        baseStartDateStr = self.baseStartDateStr
        baseEndDateStr = self.baseEndDateStr

        windFactorNameStr = 'open'
        colNameStr = 'open'
        dbUpdateDateFiledStr = 'open_update_date'
        dbUpdateDateFieldAliasStr = ' Open '

        funcObj = StockDailyFactorGeneralFunctions()

        funcObj.writeBaseDataToMongoDB(baseStartDateStr, baseEndDateStr, windFactorNameStr, colNameStr, dbUpdateDateFiledStr, dbUpdateDateFieldAliasStr)

    def updateOpenToMongoDB(self):

        windFactorNameStr = 'open'
        colNameStr = 'open'
        dbUpdateDateFiledStr = 'open_update_date'
        dbUpdateDateFieldAliasStr = ' Open '

        funcObj = StockDailyFactorGeneralFunctions()

        funcObj.updateDataToMongoDB(windFactorNameStr, colNameStr, dbUpdateDateFiledStr, dbUpdateDateFieldAliasStr)

    def writeBaseHighToMongoDB(self):
        baseStartDateStr = self.baseStartDateStr
        baseEndDateStr = self.baseEndDateStr

        windFactorNameStr = 'high'
        colNameStr = 'high'
        dbUpdateDateFiledStr = 'high_update_date'
        dbUpdateDateFieldAliasStr = ' High '

        funcObj = StockDailyFactorGeneralFunctions()

        funcObj.writeBaseDataToMongoDB(baseStartDateStr, baseEndDateStr, windFactorNameStr, colNameStr, dbUpdateDateFiledStr, dbUpdateDateFieldAliasStr)

    def updateHighToMongoDB(self):

        windFactorNameStr = 'high'
        colNameStr = 'high'
        dbUpdateDateFiledStr = 'high_update_date'
        dbUpdateDateFieldAliasStr = ' High '

        funcObj = StockDailyFactorGeneralFunctions()

        funcObj.updateDataToMongoDB(windFactorNameStr, colNameStr, dbUpdateDateFiledStr, dbUpdateDateFieldAliasStr)

    def writeBaseLowToMongoDB(self):
        baseStartDateStr = self.baseStartDateStr
        baseEndDateStr = self.baseEndDateStr

        windFactorNameStr = 'low'
        colNameStr = 'low'
        dbUpdateDateFiledStr = 'low_update_date'
        dbUpdateDateFieldAliasStr = ' Low '

        funcObj = StockDailyFactorGeneralFunctions()

        funcObj.writeBaseDataToMongoDB(baseStartDateStr, baseEndDateStr, windFactorNameStr, colNameStr, dbUpdateDateFiledStr, dbUpdateDateFieldAliasStr)

    def updateLowToMongoDB(self):

        windFactorNameStr = 'low'
        colNameStr = 'low'
        dbUpdateDateFiledStr = 'low_update_date'
        dbUpdateDateFieldAliasStr = ' Low '

        funcObj = StockDailyFactorGeneralFunctions()

        funcObj.updateDataToMongoDB(windFactorNameStr, colNameStr, dbUpdateDateFiledStr, dbUpdateDateFieldAliasStr)

    def writeBaseVolumeToMongoDB(self):
        baseStartDateStr = self.baseStartDateStr
        baseEndDateStr = self.baseEndDateStr

        windFactorNameStr = 'volume'
        colNameStr = 'volume'
        dbUpdateDateFiledStr = 'volume_update_date'
        dbUpdateDateFieldAliasStr = ' Volume '

        funcObj = StockDailyFactorGeneralFunctions()

        funcObj.writeBaseDataToMongoDB(baseStartDateStr, baseEndDateStr, windFactorNameStr, colNameStr, dbUpdateDateFiledStr, dbUpdateDateFieldAliasStr)

    def updateVolumeToMongoDB(self):

        windFactorNameStr = 'volume'
        colNameStr = 'volume'
        dbUpdateDateFiledStr = 'volume_update_date'
        dbUpdateDateFieldAliasStr = ' Volume '

        funcObj = StockDailyFactorGeneralFunctions()

        funcObj.updateDataToMongoDB(windFactorNameStr, colNameStr, dbUpdateDateFiledStr, dbUpdateDateFieldAliasStr)


    def writeBaseVwapToMongoDB(self):
        baseStartDateStr = self.baseStartDateStr
        baseEndDateStr = self.baseEndDateStr

        windFactorNameStr = 'vwap'
        colNameStr = 'vwap'
        dbUpdateDateFiledStr = 'vwap_update_date'
        dbUpdateDateFieldAliasStr = ' VWAP '

        funcObj = StockDailyFactorGeneralFunctions()

        funcObj.writeBaseDataToMongoDB(baseStartDateStr, baseEndDateStr, windFactorNameStr, colNameStr, dbUpdateDateFiledStr, dbUpdateDateFieldAliasStr)

    def updateVwapToMongoDB(self):

        windFactorNameStr = 'vwap'
        colNameStr = 'vwap'
        dbUpdateDateFiledStr = 'vwap_update_date'
        dbUpdateDateFieldAliasStr = ' VWAP '

        funcObj = StockDailyFactorGeneralFunctions()

        funcObj.updateDataToMongoDB(windFactorNameStr, colNameStr, dbUpdateDateFiledStr, dbUpdateDateFieldAliasStr)

    def writeBaseAmtToMongoDB(self):
        baseStartDateStr = self.baseStartDateStr
        baseEndDateStr = self.baseEndDateStr

        windFactorNameStr = 'amt'
        colNameStr = 'amt'
        dbUpdateDateFiledStr = 'amt_update_date'
        dbUpdateDateFieldAliasStr = ' AMT '

        funcObj = StockDailyFactorGeneralFunctions()

        funcObj.writeBaseDataToMongoDB(baseStartDateStr, baseEndDateStr, windFactorNameStr, colNameStr, dbUpdateDateFiledStr, dbUpdateDateFieldAliasStr)


    def updateAmtToMongoDB(self):

        windFactorNameStr = 'amt'
        colNameStr = 'amt'
        dbUpdateDateFiledStr = 'amt_update_date'
        dbUpdateDateFieldAliasStr = ' AMT '
        funcObj = StockDailyFactorGeneralFunctions()

        funcObj.updateDataToMongoDB(windFactorNameStr, colNameStr, dbUpdateDateFiledStr, dbUpdateDateFieldAliasStr)

#obj = OpenAndRelated()

#obj.writeBaseOpenToMongoDB()
#obj.updateOpenToMongoDB()

#obj.writeBaseHighToMongoDB()
#obj.updateHighToMongoDB()

#obj.writeBaseLowToMongoDB()
#obj.updateLowToMongoDB()

#obj.writeBaseVolumeToMongoDB()
#obj.updateVolumeToMongoDB()

#obj.writeBaseVwapToMongoDB()
#obj.updateVwapToMongoDB()

#obj.writeBaseAmtToMongoDB()
#obj.updateAmtToMongoDB()